#参考链接 https://blog.csdn.net/weixin_46221946/article/details/122729460
def local_response_norm(input, size, alpha=1e-4, beta=0.75, k=1.):
    # type: (Tensor, int, float, float, float) -> Tensor
    r"""Applies local response normalization over an input signal composed of
    several input planes, where channels occupy the second dimension.
    Applies normalization across channels.

    See :class:`~torch.nn.LocalResponseNorm` for details.
    """
    if not torch.jit.is_scripting():
        if type(input) is not Tensor and has_torch_function((input,)):
            return handle_torch_function(
                local_response_norm, (input,), input, size, alpha=alpha, beta=beta, k=k)
    dim = input.dim() # 重点！
    if dim < 3:
        raise ValueError('Expected 3D or higher dimensionality \
                         input (got {} dimensions)'.format(dim))
    div = input.mul(input).unsqueeze(1) # 重点！
    if dim == 3:
        div = pad(div, (0, 0, size // 2, (size - 1) // 2))
        div = avg_pool2d(div, (size, 1), stride=1).squeeze(1)
    else: # 重点！
        sizes = input.size() # 重点！
        div = div.view(sizes[0], 1, sizes[1], sizes[2], -1) # 重点！
        div = pad(div, (0, 0, 0, 0, size // 2, (size - 1) // 2)) # 重点！
        div = avg_pool3d(div, (size, 1, 1), stride=1).squeeze(1) # 重点！
        div = div.view(sizes) # 重点！
    div = div.mul(alpha).add(k).pow(beta) # 重点！
    return input / div # 重点！
